import React, { useState } from 'react';

interface CodeProps {
  url: string;
  style?: any;
  className?: string;
}

const Code: React.FC<CodeProps> = (props: CodeProps) => {
  const { className, url } = props;

  const [timestampe, setTimestampe] = useState(+new Date());

  return (
    <img
      style={{ width: '100%', height: '40px' }}
      className={className}
      onClick={() => {
        setTimestampe(+new Date());
      }}
      src={`${url}?timestampe=${timestampe}`}
      alt=""
      aria-hidden="true"
    />
  );
};

Code.defaultProps = {
  className: '',
  style: {},
};

export default Code;
